import Cookies from 'js-cookie'
const $store = require('store')
const TokenKey = '_WeliamAdmin'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function getPath() {
  return $store.get('SET_ROUTER_PATH') || JSON.stringify({ 'jurisdiction': [], 'is_super': 1 })
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function setName(name) {
  return Cookies.set(`${TokenKey}Name`, name)
}
// 设置cookie的姓名
export function setVersion(name) {
  return Cookies.set(`VERSION`, name)
}

export function setIndependent(independent) {
  return Cookies.set(`independent`, independent)
}
export function setAgent(agent_id) {
  return Cookies.set(`agent_id`, agent_id)
}
export function removeAgent(agent_id) {
  return Cookies.remove(`agent_id`, agent_id)
}

export function getVersion() {
  return Cookies.get(`VERSION`)
}

export function removeVersion() {
  return Cookies.remove('VERSION')
}

export function removeIndependent() {
  return Cookies.remove('independent')
}

export function removeIs_Jurisdiction() {
  return Cookies.remove('IS_JURISDICTION')
}

export function setPath(path) {
  // console.log(path, 'SET_ROUTER_PATH=>path')
  return $store.set(`SET_ROUTER_PATH`, path)
}

export function getName() {
  return Cookies.get(`USER_NAME`)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function removeName() {
  return Cookies.remove(`${TokenKey}Name`)
}

export function removePath() {
  return $store.remove(`SET_ROUTER_PATH`)
}

export function removeAvatar() {
  return Cookies.remove(`_WeliamAdminLogo`)
}
